package com.example.demo.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
@ResponseBody
@ControllerAdvice
public class Expection {
    @ExceptionHandler(Exception.class)
    public Object handler(Exception e) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("code", -1);
        map.put("data", null);
        map.put("msg","状态错误"+e.getMessage());
        return map;
    }
}
